﻿#include "gamearea.h"

GameArea::GameArea(QWidget *parent) : QWidget(parent)
{
    this->setFixedSize(COLUMN_COUNT*IMAGE_WIDHT,ROW_COUNT*IMAGE_HEIGHT);
}
void GameArea::paintEvent(QPaintEvent *e)
{
    Q_UNUSED(e);
    QPainter painter(this);
    if(showGameArea)
    {
        for(int i=0;i<ROW_COUNT;++i)
            for(int j=0;j<COLUMN_COUNT;++j)
            {
                if(!(*isEmpty)[i][j])
                painter.drawPixmap(j*IMAGE_WIDHT,i*IMAGE_HEIGHT,IMAGE_WIDHT,IMAGE_HEIGHT,
                                   QPixmap(QString(":/image/%1.png").arg(PixmapData[i][j])));
            }
    }
}
void GameArea::newGame()
{
    showGameArea=true;
    update();
}

